#include "stdafx.h"
#include "DebugInfo.h"

#ifdef _DEBUG
void Trace(char *fmt, ...)
{
	char out[1024];
	char *pout = out;
	SYSTEMTIME tm = {0};
	GetLocalTime(&tm);
	sprintf(out, "[%04d-%02d-%02d %02d:%02d:%02d %03d] ", tm.wYear, tm.wMonth, tm.wDay
		, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
	pout += strlen(pout);

	va_list body;
	va_start(body, fmt);
	vsprintf(pout, fmt, body);     // 译注：格式化输入的字符串 fmtt
	va_end(body);                 //       到输出字符串 ou
	OutputDebugStringA(out);       // 译注：输出格式化后的字符串到调试器
}
#endif

//#ifdef _DEBUG
void TraceFile(FILE *file, char *fmt, ...)
{
	char out[1024];
	char *pout = out;
	SYSTEMTIME tm = {0};
	GetLocalTime(&tm);
	sprintf(out, "[%04d-%02d-%02d %02d:%02d:%02d %03d] ", tm.wYear, tm.wMonth, tm.wDay
		, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
	pout += strlen(pout);

	va_list body;
	va_start(body, fmt);
	vsprintf(pout, fmt, body);     // 译注：格式化输入的字符串 fmtt
	va_end(body);                 //       到输出字符串 ou
//	OutputDebugString(out);       // 译注：输出格式化后的字符串到调试器
//	fwrite( out, 1, strlen(out), file );
}
//#endif
